<?php
class BannersQuery extends DomArQuery {
	
	public static function c() {
		return new BannersQuery();
	}
	
	public function __construct() {
		$this->from('banners','t');
	}
	
	public function onlyForDate( $stamp ) {
		$date = new DomDateTime( $stamp );
		$this->where('t.start <= \''.$date->date().'\' AND t.end >= \''.$date->date().'\' AND (t.onPairedDays = 0 or t.onPairedDays = '.(date('j',(int)$date->getStamp())%2 == 0 ? 2 : 1).') AND t.onWeekDay'.date('N',(int)$date->getStamp()).'=1');
		return $this;
	}
	
	public function onlyPublic() {
		$this->where('t.active = 1');
		return $this;
	}
	
	public function onlyGroup( $group ) {
		$this->where('t.group = \''.addslashes($group).'\'');
		return $this;
	}
	
	public function onlyLocation( $location ) {
		$this->where('t.location = \''.addslashes($location).'\'');
		return $this;
	}
	
	
	
}
?>